<template>
  <!-- 热映 -->
  <div >
    <div class="top-rated">
      <p class="title">最受好评电影</p>
      <div class="top-rated-list">
        <a
          href="#"
          class="top-rated-item"
          v-for="item in reying"
          :key="item.id"
        >
          <div class="poster">
            <img :src="item.img" />
            <div v-if="item.globalReleased == true">
              <span class="score">观众评分:{{item.sc}}</span>
            </div>
            <div v-if="item.globalReleased == false">
              <span class="score">{{ item.wish }}想看</span>
            </div>
          </div>
          <h5 class="name">{{ item.nm }}</h5>
        </a>
      </div>
    </div>
    <ul>
      <li class="mb-outline-b" v-for="item in reying" :key="item.id">
        <router-link :to="'/item/' + item.id">
          <div class="box">
            <img :src="item.img" />
          </div>
          <div class="box2">
            <div class="box-one">
              <h3>{{ item.nm }}</h3>
              <div v-if="item.sc > 0">
                <div v-if="item.globalReleased == true">
                  观众评 <span class="item_mk">{{ item.mk }}</span>
                </div>
                <div v-if="item.globalReleased == false">
                  <span class="item_mk">{{ item.wish }}</span> 想看
                </div>
              </div>
              <div v-if="item.sc == 0">暂无评分</div>
              <div class="text">{{ item.desc }}</div>
              <div>{{ item.showInfo }}</div>
            </div>
            <div class="box3">
              <div
                class="ticket"
                :style="{ background: item.showStateButton.color }"
              >
                {{ item.showStateButton.content }}
              </div>
            </div>
          </div>
        </router-link>
      </li>
    </ul>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "reying",
  data() {
    return {
      reying: [], //保存热映电影的数组的数据
    };
  },
  mounted() {
    //使用axios  获取数据
    axios
      .get(
        "/api/mmdb/movie/v3/list/hot.json?ct=%E6%B7%B1%E5%9C%B3&ci=30&channelId=4"
      )
      .then((res) => {
        //图片是 w.h 显示会报错，需要讲 w.h 替换成 128.180
        res.data.data.hot.forEach((item) => {
          item.img = item.img.replace("w.h", "128.180"); //64*90
        });
        this.reying = res.data.data.hot;
      })
      .catch((err) => console.log(err));
  },
};
</script>

<style scoped>
.top-rated {
  padding: 12px 15px;
  background-color: #fff;
  margin-bottom: 10px;
}
.top-rated-list {
  overflow: scroll;
  white-space: nowrap;
}
.top-rated-list::-webkit-scrollbar {
  display: none;
}
.top-rated .title {
  font-size: 14px;
  color: #333;
  margin: 0 0 12px;
}
.top-rated-item {
  display: inline-block;
  width: 85px;
  overflow: hidden;
  margin-right: 10px;
  text-decoration: none;
}
.top-rated-item .poster {
  width: 85px;
  height: 115px;
  position: relative;
  margin-bottom: 6px;
}
.top-rated-item .poster img {
  height: 100%;
}
.top-rated-item .poster .score,
.top-rated-item .poster .wish {
  position: absolute;
  left: 4px;
  bottom: 2px;
  color: #faaf00;
  font-size: 11px;
  font-weight: 600;
}
.top-rated-item .name {
  font-size: 13px;
  color: #222;
  margin: 0 0 3px;
}
/* 中间内容样式 */
.mb-outline-b {
  background: url(https://s0.meituan.net/bs/myfe/canary/file/touchnode/images/dpmmweb/img/base/base64/repeat-x-bottom-outline.png)
    0 bottom repeat-x;
}
ul{
  margin-left: 10px;
}
li a {
  display: flex;
  justify-content: space-between;
  width: 100%;
  height: 100px;
  margin: 10px 0;
  text-decoration: none;
  color: #000;
}

.box {
  width: 65px;
  height: 100px;
  background-size: 100% 100%;
  margin-right: 10px;
}

.box img {
  width: 100%;
  height: 90%;
}

.box2 {
  flex-grow: 1;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
}

.box2 .box-one div {
  color: #666;
  margin-top: 7px;
}

.text {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  width: 230px;
}

h3 {
  font-size: 18px;
}

.item_mk {
  color: rgb(250, 175, 0);
  font-size: 14px;
  font-weight: 1000;
}

.box3 {
  height: 100px;
  width: 45px;
  display: flex;
  align-items: center;
  margin-right: 15px;
}

.box2 .box3 .ticket {
  width: 45px;
  line-height: 30px;
  border-radius: 15px;
  text-align: center;
  color: white;
  font-size: 12px;
}
</style>
